
package models

type SystemRole struct {
	Id          int       `json:"id" xorm:"not null pk autoincr comment('主键') INT(11)"`
	Rolename        string    `json:"rolename" xorm:"not null comment('角色名称') VARCHAR(100)"`
	Comment string    `json:"description" xorm:"not null default '' comment('描述') VARCHAR(200)"`

}
/*
返回客户端结构,首字母必须大写
 */
type ClientRoleInfo struct {
	Id int
	Rolename        string

}
var systemrole = "system_role"

func (r *SystemRole) GetRow() bool {
	has, err := mEngine.Get(r)
	if err == nil && has {
		return true
	}
	return false
}
func (r *SystemRole) GetRowByName() bool {
	role := SystemRole{}
	has, err := mEngine.Where("rolename = ?", r.Rolename).Get(&role)
	if err == nil && has {
		return true
	}
	return false
}




func  (r *SystemRole) GetAllNames() []ClientRoleInfo{



	var list []ClientRoleInfo
	err:=mEngine.Table(systemrole).Select("id,rolename").Find(&list)
	if err!=nil {
		panic(err)
	}
	return list
}

